_package("alz.mui");

_import("alz.mui.Component");

/**
 * 提示框组件
 */
_class("TipBox", Component, function(){
	this._init = function(){
		_super._init.call(this);
		this._content = null;
		this._queue = [];  //消息队列，支持重复调用，依次显示提示信息
		this._msg = "";
		this._flag = false;
	};
	//<div id="page_tip" class="ui-tip" style="display:none;top:100px;left:100px;">滑动距离超过半屏可以翻页</div>
	this.create = function(parent){
		this.setParent(parent);
		var obj = this.createElement(parent, "div", "wui-TipBox");
		//obj.style.display = "none";
		this.init(obj);
		return obj;
	};
	this.init = function(obj){
		_super.init.apply(this, arguments);
		this._content = this.createElement(this._self, "div", "content");
	};
	this.dispose = function(){
		this._content = null;
		_super.dispose.apply(this);
	};
	this.setFlag = function(v){
		this._flag = v;
	};
	this.setVisible = function(v){
		if(this._flag) return;
		_super.setVisible.apply(this, arguments);
	};
	this.showMsg = function(v){
		if(this._msg != v){
			this._msg = v;
			this._content.innerHTML = v;
		}
		var parent = this.getParent()._self;
		this.moveTo(
			Math.round((parent.clientWidth - this._self.offsetWidth) / 2),
			Math.round((parent.clientHeight - this._self.offsetHeight) / 2)
		);
	};
});